package com.menggudf.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.menggudf.model.ResultModel;
import com.menggudf.service.AdminPermissionServiceIf;
import com.menggudf.service.PermissionServiceIf;

@Controller
@RequestMapping("/adminPerssion")
public class UserPerssionController {
    
    @Autowired
    AdminPermissionServiceIf adminPermissionService;
    
    @Autowired
    PermissionServiceIf permissionService;
    
    @RequestMapping("/setAdminPerssion")
    @ResponseBody
    public ResultModel setAdminPerssion(
            @RequestParam(value="adminCode") String adminCode,
            @RequestParam(value="permissionIds") List<Integer> permissionIds){
                return adminPermissionService.setAdminPerssion(adminCode,permissionIds);
    }
    
    @RequestMapping("/getAllPerssions")
    @ResponseBody
    public ResultModel getAllPerssions(){
                return permissionService.getAllPerssions();
    }
    
    @RequestMapping("/getAdminPerssion")
    @ResponseBody
    public ResultModel getAdminPerssion(@RequestParam(value="adminCode") String adminCode){
                return adminPermissionService.getAdminPerssion(adminCode);
    }
    
    @RequestMapping("/getAdminPerssionCode")
    @ResponseBody
    public Map<String, Object> getAdminPerssionCode(@RequestParam(value="adminCode") String adminCode){
                return adminPermissionService.getAdminPerssionCode(adminCode);
    }

    @RequestMapping("/addAdminPerssion")
    @ResponseBody
    public ResultModel addAdminPerssion(
            @RequestParam(value="adminCode") String adminCode,
            @RequestParam(value="permissionid") String permissionid){
                return adminPermissionService.addAdminPerssion(adminCode,permissionid);
    }
    
    @RequestMapping("/delAdminPerssion")
    @ResponseBody
    public ResultModel delAdminPerssion(
            @RequestParam(value="adminCode") String adminCode,
            @RequestParam(value="permissionid") String permissionid){
                return adminPermissionService.delAdminPerssion(adminCode,permissionid);
    }
}
